﻿using System.Web.Mvc;
using CMS.Admin.Filters;
using CMS.Services.Business.User;
using CMS.Services.DTO.User;

namespace CMS.Admin.Controllers
{
    public class UserController : Controller
    {
        private readonly IUserServices _userServices;
        public UserController(IUserServices userServices)
        {
            _userServices = userServices;
        }

        // GET: User
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ActionResult Register(RegisterRequestUserModel model)
        {
            return View(_userServices.GetRegisterUserModel(model));
        }
        [UserRegister]
        [HttpPost]
        public ActionResult RegisterUser(RegisterRequestUserModel model)
        {
            //提交表单 令牌失效

            //IP防刷校验

            //验证码校验

            //Model数据格式校验
            var user = _userServices.RegisterUser(model);
            return Json(new { Id = user.Id });
        }
    }
}